package cn.bellychang.leetcode.question203;

/**
 * @author ChangLiang
 * @date 2021/1/29
 */
public class Solution4 {

    public ListNode removeElements(ListNode head, int val) {

        if (head == null) {
            return head;
        }
        if (head.val == val) {
            return removeElements(head.next, val);
        } else {
            head.next = removeElements(head.next, val);
            return head;
        }
    }
}
